#ifndef MYCHARACTOR_H
#define MYCHARACTOR_H

#include <QQuickPaintedItem>

class MyCharactor : public QQuickPaintedItem
{
    Q_OBJECT
    Q_PROPERTY(QString text WRITE setText NOTIFY textChanged)
    Q_PROPERTY(qreal x WRITE setX)
    Q_PROPERTY(qreal y WRITE setY)
public:
    explicit MyCharactor(QQuickItem *parent = nullptr);

    QString getText(){return m_text;}
    void setText(const QString value){
        if(value!=m_text){
            m_text=value;
            update();
            emit textChanged();
        }
    }

    void setY(const qreal value){
        if (!qFuzzyCompare(value,m_y)){
            m_y=value;
        }
    }
    void setX(const qreal value){
        if (!qFuzzyCompare(value,m_x)){
            m_x=value;
        }
    }

protected:
    void paint(QPainter *painter);
    QString m_text;
    qreal m_x;
    qreal m_y;

signals:
    void textChanged();
};

#endif // MYCHARACTOR_H
